package com.example.myspringframework.test;

import com.example.myspringframework.beans.factory.DisposableBean;
import com.example.myspringframework.beans.factory.InitializingBean;
import com.example.myspringframework.context.annotation.Value;
import com.example.myspringframework.stereotype.Component;

@Component
public class User implements InitializingBean, DisposableBean {
    @Value("${user.name}")
    private String name;
    @Value("${user.age}")
    private Integer age;
    
    public User() {
    }
    public User(String name, Integer age) {
        this.name = name;
        this.age = age;
    }
    public String getName() {
        System.out.println("qqqqqqqqqqqqq");
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public Integer getAge() {
        return age;
    }
    public void setAge(Integer age) {
        this.age = age;
    }
    @Override
    public String toString() {
        return super.toString() + " [name=" + name + ", age=" + age + "]";
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println(this+"初始化方法afterPropertiesSet执行了");
    }
    public void init(){
        System.out.println(this+"初始化方法init执行了");
    }

    public void destroyxml() {
        System.out.println(this+"销毁方法destroyxml执行了");
    }

    @Override
    public void destroy() throws Exception {
        System.out.println(this+"销毁方法destroy执行了");
    }
}
